<?php 
 /**
    *
    * FILE:          index.php
    * LOCATION:      /root
    * REFERENCES:    none
    * FUNCTION:      MAIN LOGIN SCREEN TO DATABASE SYSTEM
    * DEPENDENCIES:  db_connect.php
    *                			ProcessLogin.php
    * 
    * ==============================================================================
    * 
    * @version $Id: index.php,v 0.1 2007/09/3
    * @copyright Copyright (c) none
    * @author Chris Villanueva
    * @license http://opensource.org/licenses/gpl-license.php GNU General 
    * Public License (GPL)
    * 
    * ==============================================================================
    *
    * IMPORTANT NOTE:  Converting code to MVC architecture.  Login form call a model file.
    */
   //connect to database
   include('includes/db_connect.php'); 
   //get CIL locations
   $query = "SELECT * FROM lst_location";
   //set locations to $result
   $result = mysql_query($query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>The Navigational Database System : Login Page</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />	
		<meta http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
		<meta http-equiv="Pragma" content="no-cache" />
		<link rel="stylesheet" href="css/reset-fonts.css" type="text/css" media="screen, projection" />
		<link rel="stylesheet" href="css/gt-styles.css" type="text/css" media="screen, projection" />
	</head>
	<body class="gt-login">
		<!-- login box -->
		<div class="gt-login-box">
			<!-- login form head -->
			<div class="gt-login-hd">
				Navigational Database System
			</div>
			
			<div class="gt-login-box-top">
				<!-- login form -->
				<form action="./models/ProcessLogin.php" 
								class="gt-form" 
								name="loginForm" 
								method="post" 
								enctype="multipart/form-data">
					<!-- form row -->
					<div class="gt-form-row">
						<label class="gt-login-label">Username</label>  		
						<select name="user" style="width:335px" class="gt-form-text2">
						<br/>
    	
<?php    
						//loop to get location and user data from database
						while($row = mysql_fetch_array($result)) {
							$location   = $row["location"];
							$id         = $row["id"];
							//location			
							echo "<option value=\"\"> + ".$location." + </option>";
							//get users from location above
								$userQuery  = "SELECT user_name, position 
																			 FROM user 
																			 WHERE location_id = ".$id."
																			 AND status=1";
								$userResult = mysql_query($userQuery);
								while($row2 = mysql_fetch_array($userResult)) {  
									//set each user as a select value option 
									echo "<option value=\"".$row2["user_name"]."\">".$row2["user_name"]." -- ".$row2["position"]."</option>";				
								}
								echo "<option value=\"\">-------------------------------------------------------</option>";
							}
						?>
						</select>
  	  					</div>
						<!-- /form row -->
					
						<!-- form row -->
						<div class="gt-form-row">
							<label class="gt-login-label">Password</label>
							<input type="password" class="gt-form-text" name="password" id="password"/>
						</div><!-- /form row -->
					
						<!-- form row -->
						<div class="gt-form-row">
							<input type="image" src="images/gt/btn-login.jpg" value="Submit" class="gt-submit-btn" />
						</div>
						<!-- /form row -->
<?php 
        //show user session STATUS on login form
        if($_GET["Status"]) {
?>
							<p style="padding:2px; 
														border:1px solid #fff; 
														background-color:#424242; 
														color:#80FF00;
														font-weight:bold;
														text-align:center;">
							<!-- current status -->               
							<?php echo $_GET["Status"]; ?>
							</p>
<?php 
         }
						//END GET STATUS  
?>
					</form>
				<!-- /login form -->
			</div>
			<div class="gt-login-box-btm"></div>
			
			<div id="login_footer">
				<p style="font-size:11px;">
					A Web-Based Consumer File Management
				</p>
			</div>
		</div><!-- /login box -->
	</body>
</html>